<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="btn1">开启定时器</button>
    <button class="btn2">关闭定时器</button>
    <script>
        var begin = document.querySelector('.btn1');
        var stop = document.querySelector('.btn2');

        var timer = null;
        begin.addEventListener('click',function(){
            timer = setInterval(function(){
                console.log('卢本伟牛逼');
            },100)
        })
        stop.addEventListener('click',function(){
            clearTimeout(timer);
        })
    </script>
</body>
</html>